<?php
namespace app\api\model;
use think\Model;
use think\Db;
use think\Cache;
use Fixtures\Prophecy\EmptyClass;

class News extends Model{
    /**
     * 预约动态
     */
    public function selectApoStaus($user_id){
       $res= Db::query("SELECT
	o.order_time
FROM
	gx_appointment_gym gy,
	gx_order o
WHERE
	o.id = gy.order_id
AND o.`status` = 1
AND gy.user_id = ?",array($user_id));
       if(!empty($res)){
           $time=time();
          
           foreach ($res as $key=>$va){
               $res[$key]['time']=timediff(strtotime($va['order_time']),$time);
               $res[$key]['ex']=time_line4(Cache('sin'));
           }
           return $res;
       }else{
           return 0;
       }
    }
    public function quxiaoyuyue($user_id){
       $res=Db::query("SELECT
	o.order_time,
	o.order_number
FROM
	gx_appointment_gym gy,
	gx_order o
WHERE
	o.id = gy.order_id
AND gy.user_id = ?
AND o.`status` =- 1
            ",array($user_id));
       if(!empty($res)){
           foreach ($res as $key=>$va){
               $res[$key]['order_time']=date('H:i',strtotime($va['order_time']));
           }
           return $res;
       }else{
           return 0;
       }
    }
    public function yiquxiao($user_id){
     $res=   Db::query("SELECT
	gy.riqi,
	gy.appoint_time
FROM
	gx_appointment_gym gy,
	gx_order o
WHERE
	o.id = gy.order_id
AND gy.user_id = ?
AND o.`status` = 10",array($user_id));
     if(!empty($res)){
         return $res;
     }else{
         return 0;
     }
    }
}